package com.bulk.demo.insert.controller;

import com.bulk.demo.insert.service.IUserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (User)表控制层
 *
 * @author 散装java
 */
@RestController
@RequestMapping("user")
public class UserController {
    @Resource
    private IUserService userService;

    /**
     * update 锁表演示
     *
     * @param name 更新人名称
     * @return int
     */
    @GetMapping("/updateByName10s")
    public Integer updateByName10s(String name) {
        return userService.updateByName10s(name);
    }

    /**
     * update 锁表演示
     *
     * @param name 更新人名称
     * @return int
     */
    @GetMapping("/updateByName")
    public Integer updateByName(String name) {
        return userService.updateByName(name);
    }

    /**
     * update 死锁演示
     *
     * @return string
     */
    @GetMapping("/updateUserAndDept")
    public String updateUserAndDept() {
        userService.updateUserAndDept();
        return "ok";
    }

    /**
     * update 死锁演示
     *
     * @return string
     */
    @GetMapping("/updateDeptAndUser")
    public String updateDeptAndUser() {
        userService.updateDeptAndUser();
        return "ok";
    }
}
